<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>JsonPrettyPrinter (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>

  <script type="text/javascript" src="//www.google.com/jsapi"></script>
  <script type="text/javascript">
     google.load("visualization", "1", {packages:["orgchart"]});
     var _loadingVisualizations = true;
  </script>

  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
        <span class="fn">format.JsonPrettyPrinter</span>
        <span>Extends</span>
        <span class="fn-name">
          
        </span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    Formats a JSON object as a string, properly indented for display.  Supports
displaying the string as text or html.  Users can also specify their own
set of delimiters for different environments.  For example, the JSON object:

<code>{"a": 1, "b": {"c": null, "d": true, "e": [1, 2]}}</code>

Will be displayed like this:

<code>{
  "a": 1,
  "b": {
    "c": null,
    "d": true,
    "e": [
      1,
      2
    ]
  }
}</code>
  </div>


        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="local_closure_goog_format_jsonprettyprinter.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
            <li><a href="http://code.google.com/p/closure-library/source/browse/local/closure/goog/format/jsonprettyprinter.js">Git</a></li>
          </ol>
        </div>
</div>






<h2 class="g-first">Inheritance</h2>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
  <tr><td>goog.format.JsonPrettyPrinter</td><td></td></tr>
</table>
</div>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
</table>
</div>




  <h2>Constructor</h2>
      <div class="fn-constructor">
    goog.format.JsonPrettyPrinter(<span><span class="arg">delimiters</span></span>)
  </div>

   <h3>Parameters</h3>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">delimiters</span>
        : <span class="type"><a href="class_goog_format_JsonPrettyPrinter_TextDelimiters.html">goog.format.JsonPrettyPrinter.TextDelimiters</a></span>
        <div class="entryOverview">Container
    for the various strings to use to delimit objects, arrays, newlines, and
    other pieces of the output.</div>
     </td>
   </tr>
  </table>


<h2>Instance Methods</h2>


  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_format_JsonPrettyPrinter.html">
              goog.format.JsonPrettyPrinter
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.format.JsonPrettyPrinter.prototype.format"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">format<span class="args">(<span class="arg">json</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
      </div>


     <div class="entryOverview">
       Formats a JSON object as a string, properly indented for display.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">json</span>
        : <span class="type">*</span>
        <div class="entryOverview">The object to pretty print. It could be a JSON object, a
    string representing a JSON object, or any other type.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>&nbsp;
            Returns a string of the JSON object, properly indented for
    display.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_format_jsonprettyprinter.js.source.html#line84">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.format.JsonPrettyPrinter.prototype.printName_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">printName_<span class="args">(<span class="arg">name</span>,&nbsp;<span class="arg">outputBuffer</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Prints a property name to the output.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">name</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The property name.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">outputBuffer</span>
        : <span class="type"><a href="class_goog_string_StringBuffer.html">goog.string.StringBuffer</a></span>
        <div class="entryOverview">The buffer to write the
    response to.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_format_jsonprettyprinter.js.source.html#line209">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.format.JsonPrettyPrinter.prototype.printObject_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">printObject_<span class="args">(<span class="arg">val</span>,&nbsp;<span class="arg">outputBuffer</span>,&nbsp;<span class="arg">indent</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Formats a property value based on the type of the propery.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">val</span>
        : <span class="type">*</span>
        <div class="entryOverview">The object to format.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">outputBuffer</span>
        : <span class="type"><a href="class_goog_string_StringBuffer.html">goog.string.StringBuffer</a></span>
        <div class="entryOverview">The buffer to write the
    response to.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">indent</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">The number of spaces to indent each line of the
    output.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_format_jsonprettyprinter.js.source.html#line111">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.format.JsonPrettyPrinter.prototype.printSpaces_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">printSpaces_<span class="args">(<span class="arg">indent</span>,&nbsp;<span class="arg">outputBuffer</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Print a number of space characters to the output.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">indent</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">The number of spaces to indent the line.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">outputBuffer</span>
        : <span class="type"><a href="class_goog_string_StringBuffer.html">goog.string.StringBuffer</a></span>
        <div class="entryOverview">The buffer to write the
    response to.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_format_jsonprettyprinter.js.source.html#line244">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.format.JsonPrettyPrinter.prototype.printValue_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">printValue_<span class="args">(<span class="arg">val</span>,&nbsp;<span class="arg">typeOf</span>,&nbsp;<span class="arg">outputBuffer</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Prints a property name to the output.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">val</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span><span>&nbsp;|&nbsp;</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span><span>&nbsp;|&nbsp;</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span>
        <div class="entryOverview">The property value.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">typeOf</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The type of the value.  Used to customize
    value-specific css in the display.  This allows clients to distinguish
    between different types in css.  For example, the client may define two
    classes: "goog-jsonprettyprinter-propertyvalue-string" and
    "goog-jsonprettyprinter-propertyvalue-number" to assign a different color
    to string and number values.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">outputBuffer</span>
        : <span class="type"><a href="class_goog_string_StringBuffer.html">goog.string.StringBuffer</a></span>
        <div class="entryOverview">The buffer to write the
    response to.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_format_jsonprettyprinter.js.source.html#line229">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>




<h2>Instance Properties</h2>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_format_JsonPrettyPrinter.html">
              goog.format.JsonPrettyPrinter
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.format.JsonPrettyPrinter.prototype.delimiters_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">delimiters_</span>
        : <span class="type"><a href="class_goog_format_JsonPrettyPrinter_TextDelimiters.html">goog.format.JsonPrettyPrinter.TextDelimiters</a></span>
     </div>


     <div class="entryOverview">
       The set of characters to use as delimiters.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_format_jsonprettyprinter.js.source.html#line65">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>





  <a name="goog.format.JsonPrettyPrinter.prototype.jsonSerializer_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">jsonSerializer_</span>
        : <span class="type"><a href="class_goog_json_Serializer.html">goog.json.Serializer</a></span>
     </div>


     <div class="entryOverview">
       Used to serialize property names and values.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_format_jsonprettyprinter.js.source.html#line73">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>










<div class="section">
  <table class="horiz-rule">


  </table>
</div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>
      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Package format</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">Package Reference</h2>
            <div id="sideTypeIndex" rootPath="" current="format.JsonPrettyPrinter"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
